﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;
using PTA;

namespace PTA.Web
{
    public class ValidateButton : System.Web.UI.WebControls.Button
    {
        public string ValidateSelector
        {
            get
            {
                return  (string)ViewState["ValidateSelector"];
            }
            set
            {
                ViewState["ValidateSelector"] = value;
            }
        }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            string parent = (string)ViewState["ValidateSelector"];
            if (parent != null)
            {
                writer.AddAttribute("validatepane", parent);
            }
            base.AddAttributesToRender(writer);
        }

        protected override void OnPreRender(EventArgs e)
        {
            this.CssClass = string.Join(" ", this.CssClass ?? string.Empty, "validatebutton");
            base.OnPreRender(e);
        }
    }
}
